#pragma once
#ifndef __G_OBSERVER_H__
#define __G_OBSERVER_H__

#include <list>

#include "GTypes.h"
#include "GBitContainer.h"

namespace GUtil
{
	class GObservable;

	typedef GBitContainer<GUInt32>	GObserverType;

	typedef GBitContainer<GUInt32>	GMessageId;
	#define G_OM_STOP_OBSERVING		0xFFFFFFFF
	

	class GObserver
	{
	friend class GObservable;

	typedef std::list<GObservable*>	ObservableList;

	private:
		GObserverType		ObserverType;
		ObservableList		Observables;

		void				AppendObservable(GObservable* Observable);
		void				RemoveObservable(GObservable* Observable);

	protected:
							GObserver();
		virtual				~GObserver();

		void				UnbindFromObservables();

	public:
		void				SetObserverType(GObserverType Type);
		GObserverType		GetObserverType() const;

		virtual void		HandleMessage(GObservable* Observable, GMessageId Message, void* Data) = 0;
		
	};

};

#endif